#include<bits/stdc++.h>
using namespace std;
const int NN=1e5+4;
int f[NN];
vector<int>g[NN];
multiset<int,greater<int> >p[NN];
void dfs(int u,int fa)
{
	for(int i=0;i<g[u].size();i++)
	{
		int v=g[u][i];
		if(v==fa)
			continue;
		dfs(v,u);
		if(p[v].size()>p[u].size())
			swap(p[u],p[v]);
		for(auto t:p[v])
			p[u].insert(t);
	}
	int w1=0,w2=0;
	if(p[u].size())
	{
		w1=*p[u].begin();
		p[u].erase(p[u].begin());
	}
	if(p[u].size())
	{
		w2=*p[u].begin();
		p[u].erase(p[u].begin());
	}
	f[u]=w1+w2;
	if(w1%2||w2%2||!w2)
		f[u]++;
	else
		p[u].insert(1);
	p[u].insert(f[u]);
}
int main()
{
	freopen("bird.in","r",stdin);
	freopen("bird.out","w",stdout);
	int n;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1,0);
	printf("%d",f[1]);
	return 0;
}
